// pages/imageApi/imageApi.js
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  choseImage: function(){
    wx.chooseImage({
      success: function(res) {
        console.log(res)
      },
    })
  },
  previewImage: function(){
    wx.previewImage({
      urls: ['../../images/cute-dog.jpg'],
      success: function(){
        console.log('success')
      },
      fail: function(){
        console.log('failed')
      }
    })
  },
  getImageInfo: function(){
    wx.getImageInfo({
      src: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1534935896790&di=7db074db7c15019c543f5398d05dff82&imgtype=0&src=http%3A%2F%2Fwww.pig66.com%2Fuploadfile%2F2018%2F0110%2F20180110103105346.jpg',
      success: function(res){
        console.log(res);
      }
    })
  },
  saveImageToPhotosAlbum: function(){
    wx.saveImageToPhotosAlbum({
      filePath: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1534935896790&di=7db074db7c15019c543f5398d05dff82&imgtype=0&src=http%3A%2F%2Fwww.pig66.com%2Fuploadfile%2F2018%2F0110%2F20180110103105346.jpg',
      success: function() {
        console.log('保存成功！');
      }
    })
  }
})